package org.apache.derby.drda;

import org.apache.derby.impl.drda.NetworkServerControlImpl;

import java.io.PrintWriter;
import java.net.InetAddress;
import java.util.Properties;

/**
 * @author ex_chenzy59
 * @since 2025/3/5
 *
 */
public class NetworkServerControl {
    public final static int DEFAULT_PORTNUMBER = 1527;

    private final static String DERBYNET_JAR = "derbynet.jar";
    private final static String DERBY_HOSTNAME_WILDCARD = "0.0.0.0";
    private final static String IPV6_HOSTNAME_WILDCARD = "::";
    private final static String SOCKET_PERMISSION_HOSTNAME_WILDCARD = "*";

    private NetworkServerControlImpl serverImpl;
    public NetworkServerControl() throws Exception{
        serverImpl = new NetworkServerControlImpl();
    }
    public NetworkServerControl(InetAddress address, int portNumber, String userName, String password) throws Exception{
        serverImpl = new NetworkServerControlImpl(address, portNumber,userName, password);
    }
    public NetworkServerControl(String userName, String password)throws Exception{
        serverImpl = new NetworkServerControlImpl(userName, password);
    }
    public NetworkServerControl(InetAddress address,int portNumber) throws Exception{
        serverImpl = new NetworkServerControlImpl(address, portNumber);
    }
    public void setTraceDirectory(String traceDirectory)throws Exception{
        serverImpl.sendSetTraceDirectory(traceDirectory);
    }
    public void  ping() throws Exception{
        serverImpl.ping();
    }
    public void start(PrintWriter consoleWriter) throws Exception{
        serverImpl.start(consoleWriter);
    }
    public void logConnections(boolean on) throws Exception{
        serverImpl.logConnections(on);
    }
    public void trace(boolean on)throws Exception{
        serverImpl.trace(on);
    }
    public void trace(int connNum, boolean on)
            throws Exception
    {
        serverImpl.trace(connNum, on);
    }
    protected void setClientLocale(String locale)
    {
        serverImpl.setClientLocale( locale );
    }
    public Properties getCurrentProperties() throws Exception
    {
        return serverImpl.getCurrentProperties();
    }
    public void setMaxThreads(int max) throws Exception
    {
        serverImpl.netSetMaxThreads(max);
    }
    public void setTimeSlice(int timeslice) throws Exception
    {
        serverImpl.netSetTimeSlice(timeslice);
    }
    public void shutdown()
            throws Exception
    {
        serverImpl.shutdown();
    }
}
